<script setup lang="ts">
import {type Data} from '../types/data'
// 1. 定义类型
type PropsType = {
    color: string
    size?: string
    btnType?: 'success' | 'danger' | 'warning'
}
// 2. 使用defineProps注解类型
// 3. 添加默认值 withDefaults
const props = withDefaults(defineProps<PropsType>(), {
    size: 'middle',
    btnType: 'success'
})

// 子传父 添加类型
type EmitsType = {
  (e: 'get-msg', msg: string): void
  (e: 'get-list', data:Data[]): void
}

const emit = defineEmits<EmitsType>()
const clickFn = () => {
  // emit("get-msg", '我是个数据')
  emit("get-list", [{id:1001, name: '对对对'}])
}
</script>

<template>
  <button @click="clickFn">按钮 - {{ color }} - {{ size }}</button>
</template>

<style lang="scss" scoped></style>
